package com.andy.buyu.server.dto;

import java.util.Set;

import com.andy.buyu.server.game.FishGame;
import com.andy.buyu.server.game.GameUser;

import io.netty.buffer.ByteBuf;

/**
 * 进入开始中的游戏113
 * @author cuiwm
 */
public class GameInfoMessage extends BaseMessage{
	
    private GameUser user;
    
    public GameInfoMessage(GameUser user) {
    	this.user = user;
	}

	@Override
	public void writeBody(ByteBuf buf) {
		FishGame game = user.getGame();
		buf.writeInt(game.getStageId());
		long startTime = game.getStartTime();
		long now = System.currentTimeMillis();
		long dura = (now - startTime);
		buf.writeInt((int) dura);
		
		Set<Integer> fishs = game.getFishs();
		buf.writeInt(fishs.size());
		for(Integer scr:fishs) {
			buf.writeInt(scr);
		}
		
		buf.writeByte(game.haveBoss()?1:0);
		buf.writeByte(game.isBossShow()?1:0);
		buf.writeByte(game.isBossDead()?1:0);
		
	}


}